home *** CD-ROM | disk | FTP | other *** search
/ 9-Digit Zip Code Directory / 9-Digit Zip Code Directory (American Business Information) (ABIZIP-12).ISO / z4src.zip / Z4Z5CNT.C < prev    next >
C/C++ Source or Header  |  1995-07-29  |  3KB  |  103 lines

  1. //----------------------------------------------------------------------------
  2. //                            MODULE DESCRIPTION
  3. //
  4. //  Module:    z4stcnt.c
  5. //   Title:    ZIP+4 Engine
  6. //  Notice:    John M. Weeder
  7. //                 Copyright (c) 1993. All rights reserved.
  8. //             This module contains proprietary information and should be 
  9. //                treated as confidential.
  10. //
  11. //----------------------------------------------------------------------------
  12. //                           MAINTENANCE HISTORY
  13. //
  14. // $Workfile$
  15. // $Revision$
  16. //   $Author$
  17. //     $Date$
  18. //      $Log$    
  19. //
  20. //----------------------------------------------------------------------------
  21. //                             MODULE NARRATIVE
  22. //
  23. //
  24. //    This module contains code to maintain the external file containing the
  25. //        count of ZIPs by state.
  26. //
  27. //    The code in this module should be written entirely in C. 
  28. //    Do not use any C++ constructs.
  29. //
  30. //    This module is portable to:
  31. //        DOS 3.X+
  32. //        MS Windows 3.X+
  33. //        OS/2 2.X+
  34. //        OS/2 2.0 PM
  35. //        SCO UNIX.
  36. //
  37. //    The following compilers are supported:
  38. //        MSC 6.0A
  39. //        MSC/C++ 7.0
  40. //        Borland C++ 3.1 for DOS
  41. //        Borland C++ 1.0 for OS/2 2.X
  42. //        SCO UNIX cc
  43. //
  44. //----------------------------------------------------------------------------
  45. #include <z4.h>
  46.  
  47.  
  48. //----------------------------------------------------------------------------
  49. //    Global data
  50. //----------------------------------------------------------------------------
  51. static CHAR szName[MAX_PATH] = "z4z5cnt.dat";
  52.  
  53.  
  54. //----------------------------------------------------------------------------
  55. //   Description:    
  56. //    Parameters:
  57. //       Returns:    TRUE if successful.
  58. //----------------------------------------------------------------------------
  59. BOOL FN_E Z4Z5CountRead(PLONG pl, SIZET cb)
  60. {
  61.     FLAG16 fs = FL_OPEN|FL_READWRITE|FL_DENYREADWRITE|FL_BINARY;
  62.     HF hf;
  63.  
  64.     if (!FnameQualify(szName, NULL, EnvGet("DATA"), 0))
  65.         return FALSE;
  66.     if (!FileOpen(&hf, szName, fs, NULL))
  67.         return FALSE;
  68.     if (!FileRead(hf, pl, cb, 0L))
  69.         {
  70.         FileClose(hf);
  71.         return FALSE;
  72.         }
  73.     FileClose(hf);
  74.     return TRUE;
  75. }
  76.  
  77.  
  78. //----------------------------------------------------------------------------
  79. //   Description:    
  80. //    Parameters:
  81. //       Returns:    TRUE if successful.
  82. //----------------------------------------------------------------------------
  83. BOOL FN_E Z4Z5CountWrite(PLONG pl, SIZET cb)
  84. {
  85.     FLAG16 fs = FL_CREATE|FL_TRUNCATE|FL_READWRITE|FL_DENYREADWRITE|FL_BINARY;
  86.     HF hf;
  87.  
  88.     if (!FnameQualify(szName, NULL, EnvGet("DATA"), 0))
  89.         return FALSE;
  90.     if (!FileOpen(&hf, szName, fs, NULL))
  91.         return FALSE;
  92.     if (!FileWrite(hf, pl, cb, 0))
  93.         {
  94.         FileClose(hf);
  95.         return FALSE;
  96.         }
  97.     FileClose(hf);
  98.     return TRUE;
  99. }
  100. //----------------------------------------------------------------------------
  101. //------------------------------- End of File --------------------------------
  102. //----------------------------------------------------------------------------
  103.